
package io.renren.utils.util.message;

import java.util.HashMap;
import java.util.Map;


/**
 * Factory for <code>PropertyMessageResources</code> instances.  The
 * configuration paramter for such instances is the base Java package
 * name of the resources entries from which our keys and values will be
 * loaded.
 *
 * @author Clark Liu
 */

public class PropertyMessageResourcesFactory extends MessageResourcesFactory {


	private static Map<String, MessageResources> instances = new HashMap<String, MessageResources>();
	
    // --------------------------------------------------------- Public Methods


    /**
     * Create and return a newly instansiated <code>MessageResources</code>.
     * This method must be implemented by concrete subclasses.
     *
     * @param config Configuration parameter(s) for the requested bundle
     */
    public synchronized MessageResources createResources(String config) {
    	MessageResources messageResources = instances.get(config);
    	if (messageResources == null) {
    		messageResources = new PropertyMessageResources(this, config, this.returnNull);
    		instances.put(config, messageResources);
		}
    	return messageResources;
    }

}
